# encoding = utf-8
class RepliesController < ApplicationController
  
  before_filter :authenticate_admin!, :only => [:new, :create, :delete]
  
  def new
    @reply = Reply.new
    @parent = params[:format]+'_id'
    @pid = params[:id]
    
    render :layout => false
  end
  
  def create
    @reply = Reply.new(params[:reply])

    if @reply.save
      flash[:success] = '回复发表成功'
    else
      flash[:error] = @reply.errors
    end

    redirect_to '/feedbacks/list'
  end
  
  def delete
    reply = Reply.find(params[:id])
    if reply.destroy
      flash[:success] = '回复删除成功'
    end
    redirect_to '/feedbacks/list'
  end
end